package ils.web.action;

import ils.domain.catalog.model.Category;
import ils.services.CatalogService;
import ils.util.SpringUtil;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: rejeevd
 * Date: 30/09/12
 * Time: 12:27
 * To change this template use File | Settings | File Templates.
 */
public class CategoriesActionTest
{
    @Test
    public void testExecute()
    {
        ApplicationContext context = SpringUtil.getApplicationContext();
        Object categoryRepository = context.getBean("categoryRepository");
        Assert.assertNotNull(categoryRepository);
        CatalogService catalogService = (CatalogService)context.getBean("catalogService");
        Assert.assertNotNull(catalogService);
        catalogService.getSubCategories(null);
        CategoriesAction action = new CategoriesAction();
        action.prepare();
        String status = action.execute();
        Assert.assertEquals("success", status);
        Assert.assertNotSame(0, action.getCategories().size());
        System.out.println("categories:");
        for(Category category : action.getCategories())
        {
            System.out.println("cat: " + category.getFullName());
        }
    }
}
